//
//  AppDelegate+Adapt.m
//  plugin
//
//  Created by hc on 17/1/6.
//
//

#import "AppDelegate+Adapt.h"
#import "HttpUtil.h"
#import "DataShare.h"

@implementation AppDelegate (Adapt)

//激活
- (void)applicationDidBecomeActive:(UIApplication *)application {
    NSLog(@"激活true");
    NSString *_socketUrl = [DataShare getSocketUrl];
    NSString *_token = [DataShare getToken];
    if (_socketUrl != nil && [_socketUrl length] > 0 && _token != nil && [_token length] > 0) {
        NSString *url = [_socketUrl stringByAppendingString:@"/status"];
        NSMutableString *paras = [[NSMutableString alloc] initWithCapacity:0];
        [paras appendString:@"status="];
        [paras appendString:LQ_ACTIVE];
        [paras appendString:@"&token="];
        [paras appendString:_token];
        NSString *dataString = [HttpUtil httpSynchronousRequestUrl:url postStr:paras];
        NSLog(@"Adapt Result:%@",dataString);
    }
}

//挂起
- (void)applicationWillResignActive:(UIApplication *)application {
    NSLog(@"激活false");
    NSString *_socketUrl = [DataShare getSocketUrl];
    NSString *_token = [DataShare getToken];
    if (_socketUrl != nil && [_socketUrl length] > 0 && _token != nil && [_token length] > 0) {
        NSString *url = [_socketUrl stringByAppendingString:@"/status"];
        NSMutableString *paras = [[NSMutableString alloc] initWithCapacity:0];
        [paras appendString:@"status="];
        [paras appendString:LQ_DISACTIVE];
        [paras appendString:@"&token="];
        [paras appendString:_token];
        NSString *dataString = [HttpUtil httpSynchronousRequestUrl:url postStr:paras];
        NSLog(@"Adapt Result:%@",dataString);
    }
}

@end
